package com.esri.core.internal.tasks.ags;

import com.esri.core.internal.tasks.TaskListener;
import com.esri.core.io.EsriServiceException;
import com.esri.core.io.UserCredentials;
import com.esri.core.map.FeatureEditResult;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class a extends com.esri.core.internal.tasks.d<FeatureEditResult> {
    private static final long serialVersionUID = 1;

    public a(c cVar, String str, UserCredentials userCredentials, TaskListener<FeatureEditResult> taskListener) {
        super(cVar, str, userCredentials, taskListener);
    }

    public a(c cVar, String str, UserCredentials userCredentials) {
        super(cVar, str, userCredentials);
    }

    @Override // com.esri.core.internal.tasks.a
    /* renamed from: a */
    public FeatureEditResult execute() throws Exception {
        String str;
        com.esri.core.internal.io.handler.j jVar;
        c cVar = (c) this.actionInput;
        StringBuilder sb = new StringBuilder(this.serviceURL);
        sb.append('/');
        sb.append(cVar.a());
        sb.append("/addAttachment");
        if (cVar.g() == null) {
            str = "";
        } else {
            str = "?gdbVersion=" + cVar.g();
        }
        sb.append(str);
        if (cVar.c() != null) {
            jVar = new com.esri.core.internal.io.handler.j(cVar.c(), "attachment", cVar.e());
        } else {
            jVar = new com.esri.core.internal.io.handler.j(cVar.d(), cVar.f(), "attachment", cVar.e());
        }
        JsonParser a = com.esri.core.internal.io.handler.h.a(sb.toString(), jVar, 1, getServiceCredentials());
        FeatureEditResult featureEditResult = null;
        if (!com.esri.core.internal.util.d.c(a)) {
            throw new EsriServiceException("Unable to parse the Add Attachement result response.");
        }
        while (a.nextToken() != JsonToken.END_OBJECT) {
            String currentName = a.getCurrentName();
            a.nextToken();
            if ("addAttachmentResult".equals(currentName)) {
                featureEditResult = FeatureEditResult.fromJson(a);
            } else {
                a.skipChildren();
            }
        }
        a.close();
        return featureEditResult;
    }
}
